﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _008_英雄的战斗ing
{
    public class Hero
    {
        public string name;//名字
        public int HP;//生命力
        public int ATK;//攻击力
        public int DEF;//防御力

        /// <summary>
        /// 英雄初始化
        /// </summary>
        public Hero(string name,int HP,int ATK, int DEF)
        {
            this.name = name;
            this.HP = HP;
            this.ATK = ATK;
            this.DEF = DEF;
        }

        public void Attack(Hero enemy)
        {
                Console.WriteLine(name + "对" + enemy.name + "发起了攻击");
                enemy.DEF = enemy.DEF - ATK;
                if(enemy.DEF >= 0)
                {
                    Console.WriteLine(name + "的攻击被" + enemy.name + "防御住了");
                    Console.WriteLine(name + "还有" + enemy.DEF + "就能让" + enemy.name + "emo了");
                }else if(enemy.DEF < 0)
                {
                    enemy.HP = enemy.HP + enemy.DEF;
                    Console.WriteLine(name + "的攻击破了" + enemy.name + "的防" );
                    Console.WriteLine(enemy.name + "的生命" + enemy.DEF);
                    if(enemy.DEF < 0)
                {
                    enemy.DEF = 0;
                }
                   
                }

            if (enemy.HP <= 0)
            {
                Console.WriteLine(name + "成功击杀" + enemy.name);
                
            }
            else
            {
                Console.WriteLine(enemy.name + "的生命还剩" + enemy.HP);
            }
        }


    }
}
